home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / utils / alignval / alignval.c next >
Encoding:
C/C++ Source or Header  |  1992-12-26  |  1.4 KB  |  72 lines

  1. #include <exec/types.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. char FileName[200];
  5. char Destination[200];
  6. void sr(char *s);
  7. main(int argc,char *argv[])
  8. {
  9.   FILE *fi,*fo;
  10.   int counter=0;
  11.   int users=0;
  12.   int linecount=0;
  13.   if(argc<2)
  14.   {
  15.     printf("AlignVal version 1.0, written by Joseph Hodge\n");
  16.     printf("This utility will insure that Validate.Dat is properly aligned\n");
  17.     printf("usage: AlignVal <filename>\n");
  18.     printf("\n");
  19.     exit(0);
  20.   }
  21.  
  22.   strcpy(FileName,argv[1]);
  23.   sr(FileName);
  24.  
  25.   fi=fopen(FileName,"r");
  26.   if(fi==NULL)
  27.   {
  28.     printf("Error, can't locate file %s\n",FileName);
  29.     exit(0);
  30.   }
  31.   
  32.   strcpy(Destination,FileName); strcat(Destination,"{key}");
  33.   fo=fopen(Destination,"w");
  34.   while(fgets(FileName,100,fi)!=NULL)
  35.   {
  36.     linecount++;
  37.     sr(FileName);strupr(FileName);
  38.     if(counter>=16 && argc==2) 
  39.     {
  40.       fprintf(fo,"\nError in account after line %d\n",linecount);
  41.       printf("Error in account after line %d\n",linecount);
  42.  
  43.       fclose(fi);
  44.       fclose(fo);
  45.       exit(0);
  46.     }
  47.     if(!strnicmp(FileName,"Name",4))
  48.     {
  49.       counter=0; users++;
  50.       fprintf(fo,"%s ",FileName); if(argc==3) fprintf(fo,"\n");
  51.     }
  52.     if(counter==6 && argc==2)
  53.     {
  54.       fprintf(fo,"%s\n",&FileName[47]);
  55.     }
  56.     counter++;
  57.   }
  58.   fclose(fi);
  59.   fclose(fo);
  60.   exit(0);
  61. }
  62.  
  63. void sr(char *s)
  64. {
  65.   register int i;
  66.   i=strlen(s)-1;
  67.   while(i>-1)
  68.   {
  69.     if(*(s+i)<=32) *(s+i)='\0'; else break;
  70.     i--;
  71.   }
  72. }